﻿Public Class clsInhPotwierdzenieZlecenia
    Inherits clsPotwierdzenieZlecenia

#Region "Attributes"

    Private mvarInhId As Integer
    Private mvarInhInformacje As String

#End Region

#Region "Properties"

    Public Property InhId() As Integer
        Get
            Return mvarInhId
        End Get
        Set(ByVal value As Integer)
            mvarInhId = value
        End Set
    End Property

    Public Property InhInformacje() As String
        Get
            Return mvarInhInformacje
        End Get
        Set(ByVal value As String)
            mvarInhInformacje = value
        End Set
    End Property

#End Region

#Region "Methods"

    Public Sub New()
        MyBase.New()
        mvarInhId = -1
        mvarInhInformacje = String.Empty
    End Sub

    Public Sub New(ByVal ID As Integer, ByVal lvarDbHolder As clsDataBase)

        MyBase.New(ID, lvarDbHolder, VAR_ERROR_HANDLER)

    End Sub

    Public Overloads Sub Save(ByVal lvarDbHolder As clsDataBase)

        lvarDbHolder.BeginTrans()

        MyBase.Save(lvarDbHolder, VAR_ERROR_HANDLER)

        lvarDbHolder.CommitTrans()

    End Sub

    Function SzukajPotwierdzenia(ByVal lvarDbHolder As clsDataBase, ByRef ErrorHandler As clsErrorHandler, ByVal Zapytanie As String) As String

        Dim lvarReader As OdbcDataReader = Nothing
        If lvarDbHolder.IsOpen Then
            Dim lvarSqlRunner As New clsSqlRunner(lvarDbHolder, "queries_application_oem", "cls_potwierdzenie_zlecenia", 1, VAR_ERROR_HANDLER)

            With lvarSqlRunner
                .AddParameter("p_zlecenie_id", Zapytanie)
                lvarReader = .ExecuteQuery
            End With

            If lvarReader.HasRows Then
                While lvarReader.Read
                    mvarInhId = CInt(IIf(IsDBNull(lvarReader.Item("id")), -1, lvarReader.Item("id")))
                    mvarInhInformacje = CStr(IIf(IsDBNull(lvarReader.Item("informacje")), String.Empty, lvarReader.Item("informacje")))
                End While
            End If

        End If
        Return mvarInhInformacje

    End Function

#End Region

End Class
